<#assign object = doc.object>
package ${object.package}.model.fields;

/**
* A list of tall the attritbutes of ${object.name} and their corresponding java.sql.Types value.
* To make his enum portable to GWT, the numeric value of Types is used, here is the legend:<br>
* Types.INTEGER      4 <br>
* Types.BIGINT      -5 <br>
* Types.DATE        91 <br>
* Types.BOOLEAN     16 <br>
* Types.CHAR         1 <br>
* Types.LONGVARCHAR -1 <br>
* Types.VARCHAR     12 <br>
* @see java.sql.Types
*/
public enum ${object.name}Fields {
	id(-5)
	,creationDate(91)
	,updateDate(91)
<#list object.attributes?children as att>
<#if att?node_name != "set" && att?node_type == "element">
	<#if att.description[0]??>
	/** ${att.description} */
	</#if>
    ,${att.@name[0]!att.@class?uncap_first}<#t>
    <#if att?node_name == "boolean">
    	(16)<#t>

    <#elseif att?node_name == "date" || att?node_name == "datetime">
    	(91)<#t>

    <#elseif att?node_name == "enum">
    	(1)<#t>

    <#elseif att?node_name == "integer">
    	(4)<#t>

    <#elseif att?node_name == "long">
    	(-5)<#t>

    <#elseif att?node_name == "object">
    	Id(-5)<#t>

    <#elseif att?node_name == "string">
    	<#if att.@maxlength[0]?number &gt; 65000>
		(-1)<#t>

		<#else>
		(12)<#t>

		</#if>
    <#elseif att?node_name == "xml" || att?node_name == "html">
    	(-1)<#t>

    <#else>
    	ERROR, undefined node ${att?node_name}
    </#if>
</#if>
</#list>;<#t>

  public int sqlType;
  private ${object.name}Fields(int sqlType) {
    this.sqlType = sqlType;
  }
  
  /**
   * @return Null, or the result of valueOf()
   */
  public static ${object.name}Fields valueOfNullSafe(String value) {
    if (value != null) {
      return valueOf(value);
    }
    return null;
  }
}
